using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ShowReminder : MonoBehaviour
{
    public string content;
    private GameObject reminder;
    private const string UIName = "UI";
    private const int reminderIndex = 1;

    private void Start()
    {
        reminder = GameObject.Find(UIName).transform.GetChild(reminderIndex).gameObject;
    }


    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag(Tags.Player))
        {
            reminder.SetActive(true);
            reminder.transform.GetChild(0).gameObject.GetComponent<Text>().text = content;
        }
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag(Tags.Player)&&reminder!=null)
            reminder.SetActive(false);
    }
}
